package cn.edu.dzkd.software.controller;

import cn.edu.dzkd.software.pojo.Bug;
import cn.edu.dzkd.software.service.BugService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/bug")
public class BugController {

    @Resource
    private BugService bugService;

    @RequestMapping(value = "/selectBugs", method = RequestMethod.GET)
    public Map<String, Object> selectBugs(@RequestParam int page,
                                           String bugName,
                                           String bugRisk) {
        return bugService.selectBugs(page, bugName, bugRisk);
    }

    @RequestMapping(value = "/selectAllbugs", method = RequestMethod.GET)
    public Map<String, Object> selectAllbugs() {
        return bugService.selectAllBugs();
    }

    @RequestMapping(value = "/insert", method = RequestMethod.POST)
    public Map<String, Object> insert(@RequestBody Bug bug) {
        return bugService.insert(bug);
    }

    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public Map<String, Object> update(@RequestBody Bug bug) {
        return bugService.update(bug);
    }

    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public Map<String, Object> delete(@RequestParam Integer id) {
        return bugService.delete(id);
    }
}
